<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <link href="bootstrap-3.3.7-dist/css/bootstrap-theme.min.css" rel="stylesheet">
    <link type="text/css" href="bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="bootstrap-3.3.7-dist/jedate/skin/jedate.css">

    <style>
        .main {
            margin: 10px 5px 5px 5px;
            overflow: hidden;
        }

        .autoPrint {
            box-sizing: border-box;
            margin: 10px 5px;
        }

        .autoPrint button {

        }

        .search {
            box-sizing: border-box;
            margin: 10px 5px;
        }

        .search input {
            margin-right: 5px;
        }

        .search button {
            width: 80px;
            height: 28px;
        }

        #line table {
            text-align: center;
        }

        #history table {
            text-align: center;
        }

        table thead th {
            text-align: center;
        }

        .last {
            width: 12px;
            background-color: #F0F0F0;
            border: none;
        }

        .table1 thead, tbody tr {
            display: table;
            width: 100%;
            table-layout: fixed;
        }

        .table1 tbody {
            display: block;
            height: 460px;
            overflow-y: scroll;
        }

        .table1 {
            margin-top: 10px;
        }

        .table2 thead, tbody tr {
            display: table;
            width: 100%;
            table-layout: fixed;
        }

        .table2 tbody {
            display: block;
            height: 460px;
            overflow-y: scroll;
        }

        .table2 {
            margin-top: 10px;
        }

        .tab-pane {
            background-color: white;
            min-height: 520px !important;
            max-height: 520px !important;
            margin-top: 2px;
        }

        .showAuto {
            display: inline-block;
        }

        .showClose {
            display: none;
        }

        #pop {
            display: none;
            color: #ffff66;
            font-weight: bolder;
            text-align: center;
            line-height: 40px;
            position: fixed;
            top: 0px;
            left: 0px;
            right: 0px;
            bottom: 0px;
            margin: auto;
            background-color: #99cc66;
            width: 180px;
            height: 40px;
            border-radius: 50px;
            z-index: 100;
        }
    </style>

</head>
<body>
<!--气泡显示打印成功-->
<div id="pop"></div>

<div class="all">
    <div class="main">
        <div class="row">
            <div class="col-md-12">
                <!-- Nav tabs -->
                <ul class="nav nav-tabs" role="tablist">
                    <li role="presentation" class="active"><a href="#line" aria-controls="line" role="tab"
                                                              data-toggle="tab">队列打印信息</a></li>
                    <li role="presentation"><a href="#history" aria-controls="history" role="tab" data-toggle="tab">历史打印记录</a>
                    </li>
                </ul>
                <!-- Tab panes -->
                <div class="tab-content">
                    <div role="tabpanel" class="tab-pane active" id="line">
                        <div class="table1">

                            <div class="autoPrint">

                                <button class="showAuto btn btn-info btn-sm">开启自动打印</button>

                                <button class="showClose btn btn-info btn-sm">关闭自动打印</button>

                            </div>

                            <table class="table table-hover table-bordered theadstyle">
                                <thead>
                                <tr class="info">
                                    <!--<th>序号</th>-->
                                    <th class="td1">排队号</th>
                                    <th class="td2">患者姓名</th>
                                    <th class="td3">患者性别</th>
                                    <th class="td4">患者年龄</th>
                                    <th class="td5">科室名</th>
                                    <th class="td6">检查室名</th>
                                    <!--<th class="td7">前方等待人数</th>-->
                                    <th class="td8">打印状态</th>
                                    <th class="td9">操作</th>
                                    <th class="last"></th>
                                </tr>
                                </thead>

                                <tbody id="waitingContent">

                                </tbody>


                            </table>
                        </div>

                    </div>


                    <div role="tabpanel" class="tab-pane" id="history">

                        <div class="search">
                            <input id="findname" placeholder="请输入队列号或姓名">
                            <button class="btn btn-info btn-sm" style="margin-right: 15px" onclick="find()">查询列表
                            </button>
                            <label style="font-weight: normal;margin-right: 15px">开始时间：<input class="dateinput dateicon"
                                                                                              id="start" type="text"
                                                                                              placeholder="开始时间"></label>
                            <label style="font-weight: normal">结束时间：<input class="dateinput dateicon" id="end"
                                                                           type="text" placeholder="结束时间"></label>
                            <button class="btn btn-info btn-sm" style="width: 100px">查询历史记录</button>
                        </div>


                        <div class="table2">
                            <table class="table table-hover table-bordered" id="already">
                                <thead>
                                <tr class="info">
                                    <!--<th>序号</th>-->
                                    <th class="td1">排队号</th>
                                    <th class="td2">患者姓名</th>
                                    <th class="td3">患者性别</th>
                                    <th class="td4">患者年龄</th>
                                    <th class="td5">科室名</th>
                                    <th class="td6">检查室名</th>
                                    <th class="td7">打印状态</th>
                                    <th class="td8">操作</th>
                                    <th class="last"></th>
                                </tr>
                                </thead>
                                <tbody id="alreadyContent">

                                </tbody>
                            </table>
                        </div>


                    </div>

                </div>

            </div>
        </div>

    </div>
</div>


<script src="bootstrap-3.3.7-dist/js/jquery-1.9.1.min.js"></script>
<script src="bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<script src="bootstrap-3.3.7-dist/jedate/jedate.js"></script>
<script src="../js/sockjs.js"></script>
<script src="../js/stomp.js"></script>


<script>
    var timer;//定时打印

    var alldata = [];//存储每次发送过来的数据

    var alreadyPrint = [];//存储动态追加的已打印的数据

    var alreadyPrint2 = [];//存储所有已打印的数据


    // 配置文件
    var g_properties;

    /**
     * 捕获异常
     */
    // window.onerror = function () {
    //     alert(arguments[0]);
    //     // 阻止在控制台中打印错误信息
    //     return true;
    // };

    //初始加载
    $(function () {
        //时间插件
        data();
        //点击 点击开启自动打印按钮  隐藏关闭自动打印按钮 并打开websocket
        $('.showAuto').click(function () {
            $('.showAuto').css('display', 'none');
            $('.showClose').css('display', 'inline-block');
            $(".lasttdone").attr({"disabled": "disabled"});
            Auto();
        });

        //点击 点击关闭自动打印按钮  隐藏开启自动打印按钮 并关闭websockt
        $('.showClose').click(function () {
            // timer.cancel();
            window.clearInterval(timer);

            $('.showAuto').css('display', 'inline-block');
            $('.showClose').css('display', 'none');
            $('.lasttdone').removeAttr("disabled");
        });

        //定时执行，3秒后执行
        var t1 = window.setTimeout(refreshCount, 1000 * 3);

        function refreshCount() {
            // 获取配置文件信息
            getClientProperties();
            //去掉定时器
            window.clearTimeout(t1);
        }
    });

    // 开启自动打印
    function Auto() {
        timer = setInterval(function () {
            if (alldata != null && alldata.length > 0) {
                var i = 0;
                console.log(JSON.stringify(alldata[i]));
                // var print = app.print(JSON.stringify(alldata[i]));
                var print = 'ok';
                if (print == 'ok') {
                    //发送一个请求通知服务端
                    //将已打印的数据存入alreadyPrint数组
                    alreadyPrint.push(alldata[i]);

                    alreadyPrint2.push(alldata[i]);
                    //加载已完成队列列表
                    already();
                    //从列表删除当前行
                    alldata.splice(i, 1);
                    // 重新加载当前页面
                    $("#waitingContent").html("");
                    var str1 = "";
                    for (var j = 0; j < alldata.length; j++) {
                        str1 += "<tr style='background-color: white'>"
                            + "<td class='td1' >" + alldata[j].queueId + "</td>"
                            + "<td class='td2'  >" + alldata[j].patientName + "</td>"
                            + "<td class='td3' >" + alldata[j].patientSex + "</td>"
                            + "<td class='td4' >" + alldata[j].patientAge + "</td>"
                            + "<td class='td5' >" + alldata[j].department + "</td>"
                            + "<td class='td6' >" + alldata[j].checkRoom + "</td>"
                            // + "<td class='td7'>" + alldata[j].waitPatientNumber + "</td>"
                            + "<td class='td8'>未打印</td>"
                            + "<td class='lasttd' ><input userType='button' onclick='handPrintOne($(this))'  " +
                            "class='btn btn-info lasttdone' value='打印' " +
                            "style='margin: -2px auto;width: 80px;height: 28px;padding: 0px'></td>"
                            + "</tr>";
                    }

                    $("#waitingContent").html(str1);

                } else {
                    alert('打印失败！');
                }
            }
        }, 3000)
    }

    // 获取客户端配置信息
    function getClientProperties() {
        // var properties = app.getClientProperties();
        var properties = '{"clientType":"2","clientId":"86e28557-dbe7-46b4-bf5c-174c4b038a00","clientName":"放射科","deptId":"门诊部放射科","checkRoomId":"门诊部放射一室,门诊部放射二室"}';
        var _properties = eval("(" + properties + ")");
        window.g_properties = _properties;

        //初始获取队列信息 发送ajax请求 将缓存队列信息存入alldata
        getDataFromServer(_properties.deptId, _properties.checkRoomId);

        //初始建立websocket连接并展示数据
        onlyConn(_properties.deptId);
    }

    //初始获取队列信息 发送ajax请求 将缓存队列信息存入alldata
    function getDataFromServer(deptId, checkRoomId) {
        var checkRooms = checkRoomId.split(",");
        for (var i = 0; i < checkRooms.length; i++) {
            $.ajax({
                // url: "http://192.168.0.61:8080/queue/cacheCheckRoom?deptId=1&checkRoomId=4",
                url: "/queue/cacheCheckRoom?deptId=" + deptId + "&checkRoomId=" + checkRooms[i],
                type: "GET",
                dataType: "json",
                success: function (res) {
                    var result = res.data;
                    for (var i = 0; i < result.length; i++) {  //将每次发送的每条数据存入alldata数组
                        alldata.push(result[i]);
                    }
                    line();
                },
                error: function (error) {
                    alert(error);
                }
            });
        }
    }

    function data() {
        jeDate({
                dateCell: "#start",
                format: "YYYY-MM-DD hh:mm:ss",
                isTime: true
            }
        );
        jeDate({
                dateCell: "#end",
                format: "YYYY-MM-DD hh:mm:ss",
                isTime: true
            }
        );
    }

    //重连timer
    var timer1;
    var socket;
    var stompClient;

    //初次连接后台 并展示数据
    function onlyConn(deptId) {
        // 建立连接对象
        socket = new SockJS('/zd-queuing-websocket');
//        var socket = new SockJS('/zd-queuing-websocket');
        // 获取STOMP子协议的客户端对象
        stompClient = Stomp.over(socket);

        // 向服务器发起websocket连接
        stompClient.connect({}, function (frame) {
                stompClient.subscribe('/newPatient/dept/' + deptId, function (msg) { // 订阅服务端提供的某个topic
                    var result = JSON.parse(msg.body);
                    var checkRoomIds = g_properties.checkRoomId.split(",");
                    console.log(checkRoomIds)
                    for (var i = 0; i < result.length; i++) {
                        for (var j = 0; j < result[i].queueDtoList.length; j++) {
                            for (var k = 0; k < checkRoomIds.length; k++) {
                                console.log(result[i].queueDtoList[j].checkId)
                                console.log(checkRoomIds[k])
                                if (checkRoomIds[k] == result[i].queueDtoList[j].checkId) {
                                    alldata.push(result[i].queueDtoList[j]);
                                }
                            }
                        }
                    }
                    //先遍历数据，后还在遍历数据时，直接判断是否alldata是否有数据然后请求打印，然后从列表删除该元素并存入已打印数组alreadyPrint
                    //调用java的打印方法，打印成功从 界面删除该信息  alldata里面也删除该数据  最后页面再重新循环遍历一次
                    if (alldata != null || alldata.length > 0) {
                        var str1;
                        //正在排队界面展示当前所有的数据
                        for (var i = 0; i < alldata.length; i++) {
                            str1 += "<tr style='background-color: white'>"
                                + "<td class='td1' >" + alldata[i].queueId + "</td>"
                                + "<td class='td2' >" + alldata[i].patientName + "</td>"
                                + "<td class='td3' >" + alldata[i].patientSex + "</td>"
                                + "<td class='td4' >" + alldata[i].patientAge + "</td>"
                                + "<td class='td5' >" + alldata[i].department + "</td>"
                                + "<td class='td6' >" + alldata[i].checkRoom + "</td>"
                                // + "<td class='td7' >" + alldata[i].waitPatientNumber + "</td>"
                                + "<td class='td8'>未打印</td>"
                                + "<td class='lasttd' ><input userType='button' " +
                                "onclick='handPrintOne($(this))' " +
                                "class='btn btn-info lasttdone' value='打印' " +
                                "style='margin: -2px auto;width: 80px;height: 28px;padding: 0px'></td>"
                                + "</tr>";
                            $("#waitingContent").html(str1);
                        }
                    } else {
                        console.log('暂无数据！')
                    }
                });
            },
            function errorCallBack(error) {
                // 连接发生错误时的处理函数
                timer1 = setInterval(function () {
                    console.log("重连");
                    socket = new SockJS('/zd-queuing-websocket');
                    stompClient = Stomp.over(socket);
                    stompClient.connect({},
                        //成功回调
                        function (frame) {
                            stompClient.subscribe('/newPatient/dept/' + deptId, function (msg) { // 订阅服务端提供的某个topic
                                var result = JSON.parse(msg.body);
                                for (var i = 0; i < result.length; i++) {
                                    for (var j = 0; j < result[i].queueDtoList.length; j++) {
                                        alldata.push(result[i].queueDtoList[j]);
                                    }
                                }
                                //先遍历数据，后还在遍历数据时，直接判断是否alldata是否有数据然后请求打印，然后从列表删除该元素并存入已打印数组alreadyPrint
                                //调用java的打印方法，打印成功从 界面删除该信息  alldata里面也删除该数据  最后页面再重新循环遍历一次
                                if (alldata != null || alldata.length > 0) {
                                    var str1;
                                    //正在排队界面展示当前所有的数据
                                    for (var i = 0; i < alldata.length; i++) {
                                        str1 += "<tr style='background-color: white'>"
                                            + "<td class='td1' >" + alldata[i].queueId + "</td>"
                                            + "<td class='td2' >" + alldata[i].patientName + "</td>"
                                            + "<td class='td3' >" + alldata[i].patientSex + "</td>"
                                            + "<td class='td4' >" + alldata[i].patientAge + "</td>"
                                            + "<td class='td5' >" + alldata[i].department + "</td>"
                                            + "<td class='td6' >" + alldata[i].checkRoom + "</td>"
                                            // + "<td class='td7' >" + alldata[i].waitPatientNumber + "</td>"
                                            + "<td class='td8'>未打印</td>"
                                            + "<td class='lasttd' ><input userType='button' " +
                                            "onclick='handPrintOne($(this))' " +
                                            "class='btn btn-info lasttdone' value='打印' " +
                                            "style='margin: -2px auto;width: 80px;height: 28px;padding: 0px'></td>"
                                            + "</tr>";
                                        $("#waitingContent").html(str1);
                                    }
                                } else {
                                    console.log('暂无数据！')
                                }
                            });
                            if (null != timer1 && undefined != timer1) {
                                console.log("重连成功！");
                                window.clearInterval(timer1);
                                //递归调用
                                onlyConn(deptId);
                            }
                        }
                    );
                }, 2000)
            });
    }

    // 断开连接
    function disconnect() {
        connSign = false;
        if (this.stompClient) {
            this.stompClient.disconnect();
        }
    }

    //已经完成队列列表
    function already() {
        if (alreadyPrint != null || alreadyPrint.length > 0) {
            var str2;
            for (var i = 0; i < alreadyPrint.length; i++) {
                str2 = "<tr  style='background-color: white'>"
                    + "<td class='td1' >" + alreadyPrint[i].queueId + "</td>"
                    + "<td class='td2' >" + alreadyPrint[i].patientName + "</td>"
                    + "<td class='td3' >" + alreadyPrint[i].patientSex + "</td>"
                    + "<td class='td4' >" + alreadyPrint[i].patientAge + "</td>"
                    + "<td class='td5' >" + alreadyPrint[i].department + "</td>"
                    + "<td class='td6' >" + alreadyPrint[i].checkRoom + "</td>"
                    + "<td class='td8' >已打印</td>"
                    + "<td class='lasttd' ><input userType='button'  value='重新打印' " +
                    "onclick='handPrintTwo($(this))'  class='btn btn-info' " +
                    "style='margin: -2px auto;width: 80px;height: 28px;padding: 0px'></td>"
                    + "</tr>";
                $("#alreadyContent").prepend(str2);
                alreadyPrint = [];
            }
        } else {
            console.log('没有已完成的队列信息！');
        }
    }

    //查询  查询已完成队列信息的方法
    function find() {
        var value = document.getElementById('findname').value; //搜索输入框的值
        var tables = document.getElementById("already"); //需要操作的table
        var reg = new RegExp(value.trim());//校验input框里输入的值
        var flag = false;//用于提示是否查到该信息
        var sign = 0;//用于判断是否是第一个查找的元素
        if (value.trim() != '') {
            for (var i = alreadyPrint2.length - 1; i >= 0; i--) {
                //模糊匹配
                if (alreadyPrint2[i].queueId.match(reg) || alreadyPrint2[i].patientName.match(reg)) {
                    sign++;
                    //为匹配行添加背景颜色
                    tables.tBodies[0].rows[(alreadyPrint2.length - i - 1)].style.background = "#ffe4e1";
                    // 滚动条滚动到指定位置
                    var num = Number(alreadyPrint2.length - i - 1);//获取匹配的行号,i从0开始
                    if (sign == 1) {  //滚动到查找的第一条数据
                        var scrollheight = $('table#already tr').height() * num;//滚动条滚动高度，tr高度乘以行号
                        $('#alreadyContent').scrollTop(scrollheight);//滚动条滚动
                    }
                    flag = true;//查到该元素
                } else {
                    //未匹配行背景颜色为白色
                    tables.tBodies[0].rows[alreadyPrint2.length - i - 1].style.background = "#FFF";
                }
            }
            //未查到该信息 弹出提示
            if (!flag) {
                alert("未查到该信息！");
            }
        } else {
            // 没有找到，清屏界面
            // alert('请输入查询条件后查询');
            $.each(alreadyPrint2, function (i, el) {
                var tables = document.getElementById("already"); //需要操作的table
                tables.tBodies[0].rows[i].style.background = "#FFF";
            });

        }
    }

    //未打印界面  打印方法
    function handPrintOne(item) {
        var data1 = [{
            queueId: '',
            patientName: '',
            patientSex: '',
            patientAge: '',
            department: '',
            checkRoom: '',
            waitPatientNumber: '',
            printResult: ''
        }];
        var data2 = [{
            queueId: '',
            patientName: '',
            patientSex: '',
            patientAge: '',
            department: '',
            checkRoom: '',
            waitPatientNumber: '',
            printResult: ''
        }];

        data1[0].queueId = item.parent().parent().children("td").eq(0).text();
        data1[0].patientName = item.parent().parent().children("td").eq(1).text();
        data1[0].patientSex = item.parent().parent().children("td").eq(2).text();
        data1[0].patientAge = item.parent().parent().children("td").eq(3).text();
        data1[0].department = item.parent().parent().children("td").eq(4).text();
        data1[0].checkRoom = item.parent().parent().children("td").eq(5).text();
        // data1[0].waitPatientNumber = item.parent().parent().children("td").eq(6).text();
        // data1[0].printResult = item.parent().parent().children("td").eq(7).text();
        data1[0].printResult = item.parent().parent().children("td").eq(6).text();

        data2[0].queueId = item.parent().parent().children("td").eq(0).text();
        data2[0].patientName = item.parent().parent().children("td").eq(1).text();
        data2[0].patientSex = item.parent().parent().children("td").eq(2).text();
        data2[0].patientAge = item.parent().parent().children("td").eq(3).text();
        data2[0].department = item.parent().parent().children("td").eq(4).text();
        data2[0].checkRoom = item.parent().parent().children("td").eq(5).text();
        // data2[0].waitPatientNumber = item.parent().parent().children("td").eq(6).text();
        // data2[0].printResult = item.parent().parent().children("td").eq(7).text();
        data2[0].printResult = item.parent().parent().children("td").eq(6).text();

        // var print;
        //从列表删除当前行
        for (var index in alldata) {
            if (alldata[index].queueId === data2[0].queueId) {
                // print = app.print(JSON.stringify(alldata[index]));
                console.log(alldata[index]);
            }
        }

        // var print = app.print(JSON.stringify(data1[0]));
        var print = 'ok';
        if (print == 'ok') {

            // endPrint(data1[0].deptId, checkRoomId, data1[0].queueId, inspectId)

            //打印成功气泡
            pop(data2[0].queueId);
            //发送一个请求通知服务端
            //将已打印的数据存入alreadyPrint数组
            alreadyPrint.push(data2[0]);
            alreadyPrint2.push(data2[0]);
            //加载已完成队列列表
            already();
            //从列表删除当前行
            for (var index in alldata) {
                if (alldata[index].queueId === data2[0].queueId) {
                    console.log(alldata[index])
                    // 发送打印完请求
                    endPrint(alldata[index].departmentId, alldata[index].checkId, alldata[index].queueId, alldata[index].inspectId)
                    alldata.splice(index, 1);
                }
            }

            $("#waitingContent").html("");
            var str1;

            for (var i = 0; i < alldata.length; i++) {
                str1 += "<tr style='background-color: white'>"
                    + "<td class='td1' >" + alldata[i].queueId + "</td>"
                    + "<td class='td2'  >" + alldata[i].patientName + "</td>"
                    + "<td class='td3' >" + alldata[i].patientSex + "</td>"
                    + "<td class='td4' >" + alldata[i].patientAge + "</td>"
                    + "<td class='td5' >" + alldata[i].department + "</td>"
                    + "<td class='td6' >" + alldata[i].checkRoom + "</td>"
                    // + "<td class='td7'>" + alldata[i].waitPatientNumber + "</td>"
                    + "<td class='td8'>未打印</td>"
                    + "<td class='lasttd' ><input userType='button' onclick='handPrintOne($(this))'  class='btn btn-info lasttdone' value='打印' style='margin: -2px auto;width: 80px;height: 28px;padding: 0px'></td>"
                    + "</tr>";
                $("#waitingContent").html(str1);
            }
        } else {
            console.log('打印失败！');
        }

    }

    //已完成队列  打印方法
    function handPrintTwo(item2) {
        var data1 = [{
            queueId: '',
            patientName: '',
            patientSex: '',
            patientAge: '',
            department: '',
            checkRoom: '',
            waitPatientNumber: '',
            printResult: ''
        }];

        data1[0].queueId = item2.parent().parent().children("td").eq(0).text();
        data1[0].patientName = item2.parent().parent().children("td").eq(1).text();
        data1[0].patientSex = item2.parent().parent().children("td").eq(2).text();
        data1[0].patientAge = item2.parent().parent().children("td").eq(3).text();
        data1[0].department = item2.parent().parent().children("td").eq(4).text();
        data1[0].checkRoom = item2.parent().parent().children("td").eq(5).text();
        data1[0].waitPatientNumber = item2.parent().parent().children("td").eq(6).text();
        data1[0].printResult = item2.parent().parent().children("td").eq(7).text();

        // var print = app.print(JSON.stringify(data1[0]));

        // var print;
        //从列表删除当前行
        for (var index in alldata) {
            if (alldata[index].queueId === data1[0].queueId) {
                // print = app.print(JSON.stringify(alldata[index]));
                console.log(alldata[index]);
            }
        }

        // var print = app.print(JSON.stringify(data1[0]));

        var print = 'ok';
        if (print == 'ok') {
            //提示打印成功气泡
            pop(data1[0].queueId);
            //发送一个请求通知服务端
            //去掉打印的背景颜色
            $.each(alreadyPrint2, function (i, el) {
                var tables = document.getElementById("already"); //需要操作的table
                tables.tBodies[0].rows[i].style.background = "#FFF";
            });

        } else {
            console.log('打印失败！');
        }
    }

    //获取缓存队列展示方法
    function line() {
        var str1;
        for (var i = 0; i < alldata.length; i++) {
            if (alldata[i].printStatus != 1) {
                str1 += "<tr style='background-color: white'>"
                    + "<td class='td1' >" + alldata[i].queueId + "</td>"
                    + "<td class='td2'  >" + alldata[i].patientName + "</td>"
                    + "<td class='td3' >" + alldata[i].patientSex + "</td>"
                    + "<td class='td4' >" + alldata[i].patientAge + "</td>"
                    + "<td class='td5' >" + alldata[i].department + "</td>"
                    + "<td class='td6' >" + alldata[i].checkRoom + "</td>"
                    // + "<td class='td7'>" + alldata[i].waitPatientNumber + "</td>"
                    + "<td class='td8'>未打印</td>"
                    + "<td class='lasttd' ><input userType='button' onclick='handPrintOne($(this))'  " +
                    "class='btn btn-info lasttdone' value='打印' " +
                    "style='margin: -2px auto;width: 80px;height: 28px;padding: 0px'></td>"
                    + "</tr>";
                $("#waitingContent").html(str1);
            } else {
                //将已打印的数据存入alreadyPrint数组
                alreadyPrint.push(alldata[i]);
                alreadyPrint2.push(alldata[i]);
                //加载已完成队列列表
                already();
            }
        }
    }

    //新加的气泡代码
    function pop(item) {

        document.getElementById('pop').innerHTML = item + '打印成功！';
        document.getElementById('pop').style.display = "block";

        var t1 = setTimeout(function () {
            document.getElementById('pop').style.display = "none";

            window.clearTimeout(t1);
        }, 2500);
    }

    // 打印完成发送请求
    function endPrint(deptId, checkRoomId, queueId, inspectId) {
        $.ajax({
            url: "/zd-server/printFinish",
            type: "post",
            dataType: "json",
            data: {
                deptId: deptId,
                checkRoomId: checkRoomId,
                queueId: queueId,
                inspectId: inspectId
            },
            success: function (data) {

            },
            error: function (data) {
                alert("修改打印信息失败");
            }
        });
    }

</script>
</body>
</html>